<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" src="<%=path %>/static/utf8-jsp/ueditor.all.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>

<SCRIPT type="text/javascript">
    <!--
    var formSetting = {
    		po:'QhNotice',
    		title:"系统公告编辑",
    		formid:"formedit",
    		hiddens:["id","uid","usertype","note","createUser","createDateTime","modifyUser","modifyDateTime","state"],
    	fields:[
    	     [
    	        {tdwidth:100,title:"接收人",type:"text",name:"recName",width:150,datatype:"Require",msg:"请选择接收人！"}
    		 ],
             [
                {title:"标题",type:"text",name:"title",width:800,datatype:"Require",msg:"请输入标题！"}
             ],
             [
                {title:"内容",type:"div",name:"editNoticeNote",width:800}
             ]
             ],
		toolbar:{align:'right',buttons:[
		                 			  {
		                 			    	 id:'save',
		                 			    	 title:'保存',
		                 			    	 handlers:{
		                 			    		 click: function(){
		                 			    			 if(!Validator.Validate(document.getElementById('formedit'),0)){
		                 			    			    return;
		                 			    			 }
		                 			    			 $.getJSON(g_path+"/public/common/addNotice.htmls",{uid:$("input[name=uid]").val(),usertype:$("input[name=usertype]").val(),type:encodeURI("系统消息"),title:encodeURI($("input[name=title]").val()),note:encodeURI(ueNoticeNote.getContent())},function(data){
		                 			    			    layer.msg("公告已发送！");
		                 			    			 });
		                 			    		 }
		                 			    	 }
		                 			     }
		                 			 ]}
    }

	var form;
    $(document).ready(function(){
    	form = new FormView("formview",formSetting);
    	form.init();

    	var id='<%=request.getParameter("id")%>';
    	if(id!=null&&id!=""){
    	   form.loadData(id, "QhTask");
    	}

		ajustHeight();
    });

    var $$ = function(func){
        if (document.addEventListener) {
            window.addEventListener("load", func, false);
        }
        else if (document.attachEvent) {
            window.attachEvent("onload", func);
        }
    }
    $$(function(){
        $("input[name=recName]").click(function(){
            layer.open({
              	title : "选择用户",
              	type : 1,
              	skin : 'layui-layer-rim', // 加上边框
              	area : [ '500px', '380px' ], // 宽高
              	content : $("#alertBox_user"),
              	btn : [ "确认","关闭" ],
              	yes : function(index, layero) {
              	    var str="",strid="",strtype="";
              	    $("input[name='chkUser']:checked").each(function(){
              	        str+=$(this).next().text()+",";
              	        strid+=$(this).val()+",";
              	        strtype+=$(this).attr("usertype")+",";
              	    });
              	    str=trim(str);
              	    strid=trim(strid);
              	    strtype=trim(strtype);
              	    $("input[name=recName]").val(str);
              	    $("input[name=uid]").val(strid);
              	    $("input[name=usertype]").val(strtype);
                    layer.close(index);
              	},
              	end : function(ret) {
                }
            });
        });

    });
    //-->
</SCRIPT>
</head>

<body>
<div id="formview0" class="rbox1"></div>
<div id="formview" class="rbox1"></div>
<div id="list" class="rbox2"></div>

<div id="alertBox_user" style="display:none">

      <table class="ctable">
         <tr>
            <td>
               <select id="selType" style="width:90px;">
                  <option value="">选择类别</option>
                  <option value="a">普通用户</option>
                  <option value="b">广告主</option>
               </select>
               <input type="text" id="txtName" placeholder="请输入姓名/手机" />
            </td>
            <td>
               <input type="button" id="btnSearch" class="btn2" value="查询" />
               <input type="button" id="btnSel" class="btn2" value="全选" onclick="checkAlls('selUser_ul',this)" />
            </td>
         </tr>
      </table>

   <div id="alertBox_user1"></div>
</div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
   $(function(){
      loadData();
      $("#btnSearch").click(function(){
         loadData();
      });
   });
   function loadData(){
      $.getJSON(g_path+"/public/common/getUser.htmls",{type:$("#selType").val(),name:$("#txtName").val()},function(data){

         var html="<ul class='selUser_ul' id='selUser_ul'>";

         $.each(data.data,function(i,item){
            html+="<li><input type='checkbox' id='chkUser"+i+"' name='chkUser' value='"+item.id+"' usertype='"+item.type+"' /><label for='chkUser"+i+"'>"+(item.name==""?item.mobile:item.name)+"</label></li>";
         });
         html+="</ul>";
         $("#alertBox_user1").html(html);
      });
   }
</script>
</body>
</html>